#include "thermalcam.h"

int main(int argc, char* argv[])
{   
    string iniPath;
    if(argc != 2 ){
        printf("main argc error: != 2\n");
        WARNING("please input .ini file path\n");
        //return -1;
        iniPath =  "../config/DeviceConfig.ini";    // for your .ini path
    }
    else{
        iniPath =  argv[1];
        
    }
    

    //const string iniPath = "/home/ljl/Desktop/hck/thermal-hik/config/DeviceConfig.ini";  // argv[1];
    if(iniPath.find(".ini") == string::npos){
        printf("main input param error: ini path error--%s\n", iniPath.c_str());
        return -1;
    }
    bExitClient = false;
    //for run thermal camera
    thermal* thermal1 = NULL;
    try{
        thermal1 = new thermal(iniPath);
        thermal1->mthermal = thermal1;
    }
    catch(string info){
        cout << info << endl;
        delete thermal1;
        return -1;
    }
    catch(...){
        printf("thermal() error!!!\n");
        delete thermal1;
        return -1;
    }

	if ( thermal1->mhckRun_tcp() == -1)
    {
        printf("thermal1->mhckRun  error\n");

        delete thermal1;
        thermal1 = NULL;
        return -1;
    }


    while (1)
    {
        printf("please input command:\n");
        mutexExitClient.lock();
        char exit = cin.get();
        
        if(exit == 'q'){
            bExitClient = true;
            mutexExitClient.unlock();
            break;
        }
        mutexExitClient.unlock();
    }

    printf("start delete thermal1\n");
    if(thermal1 != NULL){
        delete thermal1;
        thermal1 = NULL;
    }

    cout << "\033[1;32mthermal camera exit successful\033[0m" << endl;
    return 0;

}

